#include <stdio.h>

int count = 0;

int parse_sort(int num,int *each)
{
    int i,*j,*k,temp;
    for(i = 0;i<=4;i++)
    {
        j = each + 3 - i;
        *j = num%10;
        num/=10;
    }
    for(i = 0;i<3;i++)
    for(j = each,k = each + 1;j<each+3-i;j++,k++)
    if(*j>*k)
    {
        temp = *j;
        *j = *k;
        *k = temp;
    }
    return;
}

void max_min(int *each,int *max,int *min)
{
    int *i;
    *min = 0;
    for(i = each;i<each+4;i++)
    *min = *min*10 + *i;
    *max = 0;
    for(i = each+3;i>=each;i--)
    *max = *max*10 + *i;
    return;
}

 void vr6174(int num)
{
    int each[4],max,min;
    if(num!=6174&&num)
    {
        parse_sort(num,each);
        max_min(each,&max,&min);
        num = max_min;
        printf("[%d]:%d-%d=%d\n",++count,max,min,num);

        vr6174(num);
    }
}

int main()
{
    int n;
    printf("Enter a number:");
    scanf("%d",&n);
    vr6174(n);
}